from apps.cates.models import GoodsCategory

alist = {}


def binddata(id, n):
    datas = GoodsCategory.query.filter_by(parent_id=id)
    for data in datas:
        alist[data.cat_id] = spacelength(n) + data.name
        binddata(data.cat_id, n + 2)
    return alist


def spacelength(i):
    space = ''
    for j in range(1, i):
        space += "&nbsp;&nbsp;"
    return space + "|--"
